home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 5_8.lha / 5_8 / 5_8a5.h < prev    next >
Text File  |  1993-08-08  |  538b  |  29 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. /    Uniform distribution in the interval [0,LONG_MAX)
  6. /    and [0,1).
  7. include <limits.h>
  8. lass randint
  9.  
  10.    long randx;
  11.    void getx() { randx = randx * 1103515245 + 12345; }
  12.  
  13. ublic:
  14.   randint(long s = 0)    { randx = s; }
  15.    void  seed(long s)        { randx = s; }
  16.  
  17.    int   draw()
  18.    {
  19. getx();
  20. return randx & LONG_MAX;
  21.    }
  22.  
  23.    float fdraw()
  24.    {
  25. getx();
  26. return (randx & LONG_MAX) / (float) LONG_MAX;
  27.    }
  28. ;
  29.